<template>
    <div class="container">
        <el-form
            ref="ruleFormRef"
            :model="form"
            label-width="auto"
            style="max-width: 600px"
        >
            <el-form-item
                label="选择商品"
                prop="battle"
                :rules="[
                    {
                        required: true,
                        message: '请选择商品',
                        trigger: 'change',
                    },
                ]"
            >
                <Selected v-model="form.battle" :battle-data="battle_data" />
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="submitForm(ruleFormRef)">
                    提交
                </el-button>
            </el-form-item>
        </el-form>
    </div>
</template>

<script setup lang="ts">
import { ref, reactive, watchEffect } from 'vue'
import Selected from './select.vue'
const { battle_data } = defineProps<{
    battle_data: string
}>()
const ruleFormRef = ref(null)

const form = reactive({
    battle: '',
})

const submitForm = (formEl: any) => {
    formEl.validate((valid: boolean) => {
        if (valid) {
            console.log('submit!', form)
        } else {
            console.log('error submit!')
            return false
        }
    })
}
</script>

<style lang="scss" scoped></style>
